package org.gitman.agentplatform.ui.utils;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class ResourcesLoader {
	
	private static ResourcesLoader instance;
	private String ico;
	private String img;
	
	private ResourcesLoader(){
		String installdir = System.getProperty("installDir");
		String sep = System.getProperty("file.separator");
		ico = installdir + sep + "data" + sep + "ico" + sep;
		img = installdir + sep + "data" + sep + "img" + sep;
	}
	
	public static ResourcesLoader getInstance(){
		if(instance == null){
			instance = new ResourcesLoader();
		}
		return instance;
	}	
		
	public ImageIcon getIcon(String iconName) {
		return new ImageIcon(ico + iconName);
	}
	
	
	public BufferedImage getImage(String imageName) throws IOException {
		return ImageIO.read(new File(img + imageName));
	}
}
